<?php
/*---------------------------------------------------------------------------------*/
/* Gatushu widget */
/*---------------------------------------------------------------------------------*/
class Woo_GaTest extends WP_Widget {
	var $settings = array( 'title' );

	function Woo_GaTest() {
		$widget_ops = array( 'description' => 'This is a WooThemes Google Analytics Test by zhanggang.' );
		parent::WP_Widget( false, __( 'Woo - Google Analytics', 'woothemes' ), $widget_ops );
	}

	function form( $instance ) {
		$instance = $this->woo_enforce_defaults( $instance );
		extract( $instance, EXTR_SKIP ); ?>
		<p>
			<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','woothemes'); ?></label>
			<input type="text" name="<?php echo $this->get_field_name('title'); ?>"  value="<?php echo esc_attr( $title ); ?>" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" />
		</p><?php
	}

	function update($new_instance, $old_instance) {
		$new_instance['title'] = strip_tags( $new_instance['title'] );
		return $new_instance;
	}

	function widget( $args, $instance ) {
		extract( $args, EXTR_SKIP );
		extract( $instance, EXTR_SKIP );
		echo $before_widget;
		if ( $title ) { echo $before_title . apply_filters( 'widget_title', $title, $instance, $this->id_base ) . $after_title; }
		// include( get_template_directory() . '/search-form.php' );
?>	  <a href="http://www.amazon.cn/gp/product/B005JX94LO/ref=as_li_ss_tl?ie=UTF8&amp;camp=536&amp;creative=3132&amp;creativeASIN=B005JX94LO&amp;linkCode=as2&amp;tag=zhanggang-23" onclick="javascript:_gaq.push(['_trackEvent','outbound-widget','http://www.amazon.cn']);"><img src="http://ec4.images-amazon.com/images/I/41R9859i1QL._SL500_SL135_.jpg" width="93" height="135" alt="红高粱" border="0"></a>
          <a href="http://www.amazon.cn/gp/product/B008QT8LWQ/ref=as_li_ss_tl?ie=UTF8&amp;camp=536&amp;creative=3132&amp;creativeASIN=B008QT8LWQ&amp;linkCode=as2&amp;tag=zhanggang-23" onclick="javascript:_gaq.push(['_trackEvent','outbound-widget','http://www.amazon.cn']);"><img src="http://ec4.images-amazon.com/images/I/51VYvo885-L._SL500_SS100_.jpg" width="100" alt="你早该这么玩Excel2" height="100" border="0"></a>
          <a href="http://www.amazon.cn/gp/product/B003553OJQ/ref=as_li_ss_tl?ie=UTF8&amp;camp=536&amp;creative=3132&amp;creativeASIN=B003553OJQ&amp;linkCode=as2&amp;tag=zhanggang-23"  onclick="javascript:_gaq.push(['_trackEvent','outbound-widget','http://www.amazon.cn']);"><img src="http://ec4.images-amazon.com/images/I/51VKF7X0TaL._SL500_PIsitb-sticker-arrow-big,TopRight,35,-73_OU28_SS100_.jpg" width="100" alt="别告诉我你懂PPT" height="100" border="0"></a>
	  <a href="http://vdisk.weibo.com/s/eYBgU" onclick="javascript:_gaq.push(['_trackPageview','/downloads/Advanced Web Metrics with Google Analytics 2nd Edition.pdf']); _gaq.push(['_addTrans','201210062035','Advanced Web Metrics with Google Analytics 2nd Edition','10.58','1','1.8','YueYang','Hunan','China']); _gaq.push.(['_addItem','201210062035','414000','PDF Brochure','Download','10.58','1')]; _gaq.push(['_trackTrans'];" target="_blank"><img src="http://ec4.images-amazon.com/images/I/51EsW-zNapL._SL500_PIsitb-sticker-arrow-big,TopRight,35,-73_OU28_SS100_.jpg" alt="流量的密码"></a>
<?php		echo $after_widget;
	}

	function woo_enforce_defaults( $instance ) {
		$defaults = $this->woo_get_settings();
		$instance = wp_parse_args( $instance, $defaults );
		return $instance;
	}

	/**
	 * Provides an array of the settings with the setting name as the key and the default value as the value
	 * This cannot be called get_settings() or it will override WP_Widget::get_settings()
	 */
	function woo_get_settings() {
		// Set the default to a blank string
		$settings = array_fill_keys( $this->settings, '' );
		// Now set the more specific defaults
		return $settings;
	}
}
register_widget( 'Woo_GaTest' );
